package com.ssyan.decorator;

/**
 * @author ssyan
 * @Description TODO
 * @create 2021/8/29 1:27
 * @Version 1.0
 */
public class CoffeeBar {
    public static void main(String[] args) {
        //装饰者模式下的订单：2份巧克力+1份牛奶的LongBlack

        //1.点一份LongBlack
        Drink order = new LongBlack();
        System.out.println("描述1：" + order.getDesc() + ",费用1=" + order.cost());

        //2.加入牛奶
        order = new Milk(order);
        System.out.println("描述2：" + order.getDesc() + ",费用2=" + order.cost());

        //3.加入一份巧克力
        order = new Chocolate(order);
        System.out.println("描述3：" + order.getDesc() + ",费用3=" + order.cost());

        //4.加入一份巧克力
        order = new Chocolate(order);
        System.out.println("描述4：" + order.getDesc() + ",费用4=" + order.cost());

        //5.点一份无因咖啡加豆浆加奶
        Drink order2 = new Decaf();
        order2 = new Milk(new Soy(order2));
        System.out.println("order2 描述1：" + order2.getDesc() + ",费用1=" + order2.cost());
    }
}
